﻿using System;
using System.Collections.Generic;
using System.Text;
using Soft000.Config;
using Soft000.IDAL;


namespace Soft000.DataFactory
{
    /// <summary>
        /// 数据访问层类工厂，这里尽可能避免了使用反射
        /// </summary>
    public class Factory
    {
        #region User
        /// <summary>
        /// 根据所使用的数据库创建User类的实例
        /// </summary>
        /// <returns>返回IOnLine接口</returns>
        public static IUser CreateUser()
        {
            switch (BaseConfigs.GetDbType)
            {
                //case 1://SQL Server
                //    return (IAdmin)new Soft000.SqlServerProvider.();
                case 2://Access
                    return (IUser)new Soft000.AccessProvider.User();
            }
            throw new DalFactoryException();
        }
        #endregion
        #region OnLine
        /// <summary>
        /// 根据所使用的数据库创建OnLine类的实例
        /// </summary>
        /// <returns>返回IOnLine接口</returns>
        public static IOnLine CreateOnLine()
        {
            switch (BaseConfigs.GetDbType)
            {
                //case 1://SQL Server
                //    return (IAdmin)new Soft000.SqlServerProvider.();
                case 2://Access
                    return (IOnLine)new Soft000.AccessProvider.OnLine();
            }
            throw new DalFactoryException();
        }
        #endregion

        #region Home
        /// <summary>
        /// 根据所使用的数据库创建Home类的实例
        /// </summary>
        /// <returns>返回IOnLine接口</returns>
        public static IHome CreateHome()
        {
            switch (BaseConfigs.GetDbType)
            {
                //case 1://SQL Server
                //    return (IAdmin)new Soft000.SqlServerProvider.();
                case 2://Access
                    return (IHome)new Soft000.AccessProvider.Home();
            }
            throw new DalFactoryException();
        }
        #endregion

        #region StyleCss
        /// <summary>
        /// 根据所使用的数据库创建StyleCss类的实例
        /// </summary>
        /// <returns>返回IStylecss接口</returns>
        public static IStylecss CreateStyleCss()
        {
            switch (BaseConfigs.GetDbType)
            {
                //case 1://SQL Server
                //    return (IAdmin)new Soft000.SqlServerProvider.();
                case 2://Access
                    return (IStylecss)new Soft000.AccessProvider.StyleCss();
            }
            throw new DalFactoryException();
        }
        #endregion

        #region Total
        /// <summary>
        /// 根据所使用的数据库创建Total类的实例
        /// </summary>
        /// <returns>返回ITotal接口</returns>
        public static ITotal CreateTotal()
        {
            switch (BaseConfigs.GetDbType)
            {
                //case 1://SQL Server
                //    return (IAdmin)new Soft000.SqlServerProvider.();
                case 2://Access
                    return (ITotal)new Soft000.AccessProvider.Total();
            }
            throw new DalFactoryException();
        }
        #endregion
    }
}
